import config from '@/config/MenuConfig'

class MenuManager {
    menuCfg: any
    constructor() {
        this.menuCfg = []
    }

    init(menu: any) {
        this.menuCfg = menu
        this.menuCfg.value = config
    }

    setDisable(name: string) {
        const item = this.getItemByName(name)
        item.disabled = true
    }

    setEnable(name: string) {
        const item = this.getItemByName(name)
        item.disabled = false
    }

    tirggerItemByName(name: string) {

    }

    getItemByName(name: string) {
        for (let i = 0; i < this.menuCfg.value.length; i++) {
            if (this.menuCfg.value[i].name === name) {
                return this.menuCfg.value[i]
            }
        }
    }
}

export default MenuManager